package org.datavis.event;

import org.datavis.chart.Chart;
import org.datavis.chart.ColumnChart;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class ColumnChartOnClickListener implements View.OnClickListener {

	protected Chart chart = null;
	protected Context context = null;
	protected AttributeSet attrs = null;
	
	public ColumnChartOnClickListener(Chart chart, Context context, AttributeSet attrs)
	{
		this.chart = chart;
		this.context = context;
		this.attrs = attrs;
	}
	
	public ColumnChartOnClickListener(Chart chart, Context context)
	{
		this.chart = chart;
		this.context = context;
	}
	
	//open dialog with chart
	public void onClick(View v)
	{
		Dialog dialog = new Dialog(context);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		ColumnChart chart = new ColumnChart(context, attrs);		
		chart.setData(this.chart.getData());
		chart.setBackgroundColor(Color.WHITE);
		chart.setOnClickListener(new DismissDialogOnClickListener(dialog));
		chart.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		dialog.setContentView(chart);
		dialog.show();
	}

}
